package com.bruan.d2_io;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class BufferedWriterTest2 {
    public static void main(String[] args) {
        try(Writer wirter = new FileWriter("file-io-app\\bruan.txt",true);
            BufferedWriter bw = new BufferedWriter(wirter);
        ) {
            //写字符
            bw.write('a');
            bw.write(2);
            bw.write(1);
            bw.write('定');
            bw.newLine();
            //写字符串
            bw.write("我爱你中国abc");
            bw.write("我爱你中国abc",0,5);
            bw.newLine();

            //写字符数组
            char[] buffer = {'h','e','l','l'};
            bw.write(buffer);
            bw.newLine();
            System.out.println("写入完成！");

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
